package com.yanqu.road.server.cmd.cross.marriage;

import com.yanqu.road.entity.marriage.MarriageInfo;
import com.yanqu.road.logic.pb.MarriagePb;
import com.yanqu.road.pb.marriage.MarriageProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.MarriageModule;
import com.yanqu.road.server.manger.player.GamePlayerMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import io.netty.channel.ChannelHandlerContext;


@Cmd(code = Protocol.S_CROSS_MARRIAGE_APPOINT_NOTIFY, desc = "跨服指向联姻通知")
public class CrossMarriageAppointNotifyCmd implements Command {
	@Override
	public void execute(ChannelHandlerContext ctx, YanQuMessage packet) throws Exception {
		MarriageProto.MarriageApplyTempMsg reqMsg = MarriageProto.MarriageApplyTempMsg.parseFrom(packet.getBytes());
		MarriageInfo marriageInfo = MarriagePb.parseMarriageInfo(reqMsg);
		GamePlayer player = GamePlayerMgr.getOnlinePlayer(packet.getPlayerId());
		if(null != player){
			player.getModule(MarriageModule.class).syncMarriageApply(marriageInfo);
		}
	}
}
